# 批量创建用户数据
import os
import sys
import django


base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# D:\develop\study\Django\wxPro\scripts\init_topic.py
print(os.path.abspath(__file__))
# D:\develop\study\Django\wxProNews
# print(base_dir)
sys.path.append(base_dir)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "auction.settings")
django.setup()

# 导入的包必须在上述以下才可以执行，不能放在最上面
from apps.api import models
import random

# 批量创建
user_avatar = ['https://avatar-static.segmentfault.com/115/610/1156101362-5e59f01af3a13_big64',
               'https://avatar-static.segmentfault.com/252/550/2525503357-60136e6ba5410_big64',
               'https://avatar-static.segmentfault.com/356/080/3560809772-60531b832231f_big64',
               'https://avatar-static.segmentfault.com/387/044/3870447111-5673aedad6338_big64',
               'https://p3.itc.cn/images01/20210326/0bd5fbad58224edba52b5e0da5ea1cf9.jpeg',
               'https://avatar-static.segmentfault.com/392/949/3929497632-5c75d206ad1a5_big64',
               ]
# for i in range(2,10):
#     telephone = '1300000000'+str(i)
#     nickname = "昵称-"+str(i)
#     avatar = random.choice(user_avatar)
#     models.UserInfo.objects.create(telephone=telephone,nickname=nickname,
#                                    avatar=avatar,token='b31e603e768bd02f6f0ebe1f385aee6'+str(i),
#                                    session_key='eOB{}gfgYND9loHg/KfaDrw=='.format(i),
#                                    openid='lYCm5{}f13Txys2RGp56Z9Tg34edR'.format(i)
#                                    )

for i in range(10,16):
    telephone = '130000000'+str(i)
    nickname = "昵称-"+str(i)
    avatar = random.choice(user_avatar)
    models.UserInfo.objects.create(telephone=telephone,nickname=nickname,
                                   avatar=avatar,token='b31e603e768bd02f6f0ebe1f385aee'+str(i),
                                   session_key='eO{}gfgYND9loHg/KfaDrw=='.format(i),
                                   openid='lYCm{}f13Txys2RGp56Z9Tg34edR'.format(i)
                                   )